#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  swap_test
# Version	:  1.0
# Date		:  2023/12/04
# Author	:  yaoxiyao
# Email		:  yaoxiyao@kylinos.com.cn 
# History	:     
#              Version 1.0, 2023/12/04
# Function	:  交换分区关闭和打开
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="交换分区关闭和打开"

# 目标文件
SwapFile="/proc/swaps"
DevName="/dev"

## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB(){
	return $TPASS
}


## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB(){
        return $TPASS
}


## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB(){
        testcase_1
        return $TPASS
}


## TODO ： 交换分区关闭和打开
testcase_1(){
        local dm=`grep "${DevName}" ${SwapFile} | awk '{ print $1 }'`
        CommRetParse_LTFLIB "获取${dm}"

        swapoff ${dm}
        CommRetParse_LTFLIB "关闭交换分区"

        free -m
        CommRetParse_LTFLIB "查看交换分区已关闭"

        swapon ${dm}
        CommRetParse_LTFLIB "打开交换分区"

        free -m
        CommRetParse_LTFLIB "查看交换分区已打开"
}




#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
